package com.vinjogames.entities;

import com.vinjogames.util.GameConVars;
import com.vinjogames.util.PointFFlagged;


public class MapBuildPoint {

	public int leftIndexHeight, rightIndexHeight;
	public int leftIndexDraw, rightIndexDraw;
	public int xLoc;
	public float clampHeight;
	public float clampWidth;
	public boolean used;
	
	public MapBuildPoint() {
		used = false;		
	}
	
	public MapBuildPoint(int xLocation, int height, int type) {
		used = false;
		clampHeight = height; xLoc = xLocation;
		
		switch(type) {
		case GameConVars.MAP_POINT_TYPE_BASE:
			clampWidth = GameConVars.MAP_BASE_WIDTH;
			break;
		case GameConVars.MAP_POINT_TYPE_TURRET:
			clampWidth = GameConVars.MAP_TURRET_WIDTH;
			break;
		case GameConVars.MAP_POINT_TYPE_RESOURCE:
			clampWidth = GameConVars.MAP_RESOURCE_WIDTH;
			break;
		}
		leftIndexHeight = rightIndexHeight = leftIndexDraw = rightIndexDraw = -1;
	}
	
	public void initializeIndicesAndClampHeight(PointFFlagged[] heightMap) {
		int i = 0;
		
		while(heightMap[i].x < xLoc - (clampWidth / 2.0f) && i < heightMap.length) ++i;
		while(heightMap[i].x < xLoc + (clampWidth / 2.0f) && i < heightMap.length) {
			heightMap[i].setY(clampHeight);
			++i;
		}		
		return;
	}
	
	public void initializeIndicesAndClampDraw(PointFFlagged[] drawMap) {
		int i = 0;
		while(drawMap[i].x < xLoc - (clampWidth / 2.0f)) ++i;
		while(drawMap[i].x < xLoc + (clampWidth / 2.0f)) {
			drawMap[i].setY(clampHeight);
			//drawMap[i].frozen = true;
			++i;
		}
		return;
	}
	
	public void fastClampHeight(PointFFlagged[] heightMap) {
		for(int i = leftIndexHeight; i <= rightIndexHeight; ++i) {
			heightMap[i].setY(clampHeight);
			//heightMap[i].frozen = true;
		}
	}
	
	public void fastClampDraw(PointFFlagged[] drawMap) {
		for(int i = leftIndexDraw; i <= rightIndexDraw; ++i) {
			drawMap[i].setY(clampHeight);
			//drawMap[i].frozen = true;
		}
	}
}
